import express from "./express/index.js";
const app = express();

// /user/1/2/add  -> params
app.get("/user/:id/:name/add", function (req, res, next) {
  res.end(JSON.stringify(req.params));
});
app.listen(3000);
// let paramsPath = "/user/:id/:name/add"; //  -> 正则 /user/(.+?)/(.+?)/add

// let keys = [];
// const regStr = paramsPath.replace(/:([^/]+)/g, function () {
//   // keys.push(arguments[1]);
//   return "([^/]+)";
// });
// const reg = new RegExp(regStr);
// const requestPath = "/user/1/jw/add";
// let [, ...args] = requestPath.match(reg);
// // console.log(args, keys);
// console.log(requestPath.match(pathToRegExp(paramsPath, keys)), keys);
// app.listen(3000);
